ValidatedList

open class ValidatedList<T>(defaultValue: List<T>, entryHandler: Entry<T, *>) : ValidatedField<List<T>> , List<T>

a validated list

This ValidatedField implements List, so you can directly use it as if it were an immutable list

Author

fzzyhmstrs

Since

0.1.0

Parameters

T

any non-null type

defaultValue

default list of values

entryHandler

Entry used to handle individual list entries

See also

Samples

Constructors

Link copied to clipboard
constructor(defaultValue: List<T>, entryHandler: Entry<T, *>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val size: Int

Functions

Link copied to clipboard
open override fun accept(input: List<T>)

updates the wrapped value. NOTE: this method will push updates to an UpdateManager, if any. For in-game updating consider validateAndSet

Link copied to clipboard
open override fun addFirst(p0: T)
Link copied to clipboard
open override fun addLast(p0: T)
Link copied to clipboard
open fun addListener(listener: Consumer<ValidatedField<List<T>>>)

Attaches a listener to this field. This listener will be called any time the field is written to ("set"). accept, validateAndSet, setAndUpdate and so on will all call the listener.

Link copied to clipboard
open fun andThen(p0: Consumer<in List<T>>): Consumer<List<T>>
Link copied to clipboard
fun codec(): Codec<List<T>>

Provides a Codec representing the value type of this validation, backed by the validators within as applicable

Link copied to clipboard
open operator override fun contains(element: T): Boolean
Link copied to clipboard
open override fun containsAll(elements: Collection<T>): Boolean
Link copied to clipboard
open override fun copyStoredValue(): List<T>

Creates a deep copy of the stored value and returns it

Link copied to clipboard
open fun description(fallback: String? = null): MutableText

The translated Text description from the descriptionKey. Falls back to an empty string so no tooltip is rendered.

Link copied to clipboard
open override fun descriptionKey(): String

translation key of this Translatable's description. the "description" in-game, the descriptions Enchantment Descriptions adds to enchantment tooltips are a good example.

Link copied to clipboard
open fun flags(): Byte
Link copied to clipboard
open fun forEach(p0: Consumer<in T>)
Link copied to clipboard
open override fun get(): List<T>

supplies the wrapped value

open operator override fun get(index: Int): T
Link copied to clipboard
fun getDefault(): List<T>

Provides this validations default value

Link copied to clipboard
open override fun getFirst(): T
Link copied to clipboard
open override fun getLast(): T
Link copied to clipboard

Whether this Translatable has a valid description

Link copied to clipboard
open override fun hasFlag(flag: EntryFlag.Flag): Boolean
Link copied to clipboard

Whether this Translatable has a valid translation

Link copied to clipboard
open override fun indexOf(element: T): Int
Link copied to clipboard
open override fun instanceEntry(): ValidatedList<T>

creates a deep copy of this ValidatedList return ValidatedList wrapping a deep copy of the currently stored list and passes the entry handler

Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open operator override fun iterator(): Iterator<T>
Link copied to clipboard
open override fun lastIndexOf(element: T): Int
Link copied to clipboard
open override fun listIterator(): ListIterator<T>
open override fun listIterator(index: Int): ListIterator<T>
Link copied to clipboard
fun <N> map(to: Function<List<T>, out N>, from: Function<in N, List<T>>): ValidatedField<N>

Maps this validation to a new convertible type. The default value will be applied from this delegates current storedValue

fun <N> map(defaultValue: N, to: Function<List<T>, out N>, from: Function<in N, List<T>>): ValidatedField<N>
fun <N> map(to: Function<List<T>, out N>, from: Function<in N, List<T>>, defaultValue: List<T>): ValidatedField<N>

Maps this validation to a new convertible type.

Link copied to clipboard
open fun parallelStream(): Stream<T>
Link copied to clipboard
open override fun removeFirst(): T
Link copied to clipboard
open override fun removeLast(): T
Link copied to clipboard
open override fun reversed(): MutableList<T>
Link copied to clipboard
open override fun spliterator(): Spliterator<T>
Link copied to clipboard
open fun stream(): Stream<T>
Link copied to clipboard
open override fun subList(fromIndex: Int, toIndex: Int): List<T>
Link copied to clipboard
fun <T> List<T>.supply(): Supplier<List<T>>

wraps a list in a Supplier

Link copied to clipboard
open fun <T : Any> toArray(p0: IntFunction<Array<T>>): Array<T>
Link copied to clipboard
fun toChoices(    widgetType: ValidatedChoice.WidgetType = WidgetType.POPUP,     translationProvider: BiFunction<T, String, MutableText> = BiFunction { t, _ -> t.transLit(t.toString()) },     descriptionProvider: BiFunction<T, String, Text> = BiFunction { t, _ -> t.descLit("") }): ValidatedChoice<T>

Converts this ValidatedList into ValidatedChoice wrapping this list as the valid choice options

Link copied to clipboard
open fun toCondition(condition: ValidatedField<Boolean>, fallback: Supplier<List<T>>): ValidatedCondition<List<T>>

Convert this field to a ValidatedCondition using the provided validation as a supplier. The provided condition (and any others you append) must pass for the stored value to be provided, otherwise the fallback will be supplied.

open fun toCondition(condition: Supplier<Boolean>, failMessage: Text, fallback: Supplier<List<T>>): ValidatedCondition<List<T>>

Convert this field to a ValidatedCondition. The provided condition (and any others you append) must pass for the stored value to be provided, otherwise the fallback will be supplied.

open fun toCondition(scope: String, failMessage: Text, fallback: Supplier<List<T>>): ValidatedCondition<List<T>>

Convert this field to a ValidatedCondition using the provided scope with a default boolean provider. The provided condition (and any others you append) must pass for the stored value to be provided, otherwise the fallback will be supplied. The provided scope must point to a valid boolean config scope otherwise the initial condition will never pass.

Link copied to clipboard
fun toList(vararg elements: List<T>): ValidatedList<List<T>>

wraps the provided values into a ValidatedList with this field as validation

fun toList(collection: Collection<List<T>>): ValidatedList<List<T>>

wraps the provided collection into a ValidatedList with this field as validation

Link copied to clipboard
fun toSet(vararg elements: List<T>): ValidatedSet<List<T>>

wraps the provided values into a ValidatedSet with this field as validation

fun toSet(collection: Collection<List<T>>): ValidatedList<List<T>>

wraps the provided collection into a ValidatedList with this field as validation

Link copied to clipboard
open override fun translation(fallback: String?): MutableText

The translated Text name from the translationKey. Falls back to the implementing classes Simple Name (non-translated)

Link copied to clipboard
open override fun translationKey(): String

translation key of this Translatable. the "name" in-game

Link copied to clipboard
fun trySerialize(input: Any?, errorBuilder: MutableList<String>, flags: Byte): TomlElement?
Link copied to clipboard
open override fun trySet(input: Any?)
Link copied to clipboard
open fun update(updateMessage: Text)
Link copied to clipboard

A setter method for the storedValue that first validates the value being set and then stores the post-validation result.

Link copied to clipboard

Shorthand validated number List

fun <T : Any> List<T>.validated(handler: Entry<T, *>): ValidatedList<T>

Shorthand validated List

Link copied to clipboard

Shorthand Validated Identifier using the List for validation

Link copied to clipboard
fun List<Identifier>.validatedList(list: List<Identifier>): ValidatedList<Identifier>

Shorthand Validated Identifier List, validated with a list

Link copied to clipboard
fun <T : Any> List<Identifier>.validatedRegistry(registry: Registry<T>): ValidatedList<Identifier>

Shorthand Validated Identifier List, validated with a registry

fun <T : Any> List<Identifier>.validatedRegistry(    registry: Registry<T>,     predicate: BiPredicate<Identifier, RegistryEntry<T>>): ValidatedList<Identifier>

Shorthand Validated Identifier List, validated with a predicated registry

Link copied to clipboard
fun List<Identifier>.validatedTag(tagKey: TagKey<*>): ValidatedList<Identifier>

Shorthand Validated Identifier List, validated with a tag

Link copied to clipboard
open fun widgetAndTooltipEntry(choicePredicate: ChoiceValidator<List<T>> = ChoiceValidator.any()): ClickableWidget